const webpack = require('webpack');
const merge = require('webpack-merge');
const base = require('./webpack.base.conf.js');
const path = require('path');


module.exports = function(env, argv) {
    return merge(base(env, argv), {
        plugins: [
            new webpack.HotModuleReplacementPlugin()
        ],
        target: 'web',
        mode: 'development',
        devtool: 'inline-source-map',
        devServer: {
            // headers: {
            //     server: 'nginx100'
            // },
            contentBase: [path.join(__dirname, '../dist')],
            hot: true,
            host: '0.0.0.0',
            port: 3000,
            compress: true,
            host: '0.0.0.0',
            // historyApiFallback: true,
            // inline: true,
            overlay: {
                warnings: false,
                errors: true
            },
            // open: true,
            // profile: true,
            openPage: 'index.html',
            stats: 'errors-only',
            watchOptions: {
                // 不监听的文件或文件夹，支持正则匹配
                // 默认为空
                ignored: /node_modules/,
                // 监听到变化发生后会等300ms再去执行动作，防止文件更新太快导致重新编译频率太高
                // 默认为 300ms  
                aggregateTimeout: 300,
                // 判断文件是否发生变化是通过不停的去询问系统指定文件有没有变化实现的
                // 默认每秒轮询1000次
                // poll: 1000
            },
            proxy: {
                '/gateway/**': {
                    target: 'http://192.168.1.252:9999/gateway/',
                    // target: 'http://192.168.1.140:9999/gateway/',
                    // target: 'http://192.168.1.120:9999/gateway/',
                    // target: 'http://192.168.1.154:9999/gateway/',
                    pathRewrite: {
                        '^/gateway': ''
                    }
                }
            }
            // publicPath: '/assets/'
        },
    });
}